Skip to content

Fix decoding of uncompressed 16-bit, half, float, RGB9e5 and signed texture formats - #402

Open
1915rising wants to merge 1 commit into
K0lb3:masterfrom
1915rising:fix/386-texture-formats
Open

1915rising wants to merge 1 commit into
K0lb3:masterfrom
1915rising:fix/386-texture-formats

Conversation

@1915rising

Copy link
Copy Markdown

Fixes #386.

Using the issue's test script (2x2 textures with known texels) against master, 18 of the 21 uncompressed formats in this family failed to decode: RG16, RG32, RHalf, RGHalf, RGBAHalf, RFloat, RGBAFloat, ARGBFloat, RGFloat and RGB9e5Float, plus all eight _SIGNED formats — with KeyErrors, struct unpack errors, unknown image modes and channel shifts. R16, RGB48 and RGBA64 already worked and are untouched.

The fix replaces the broken half()/rg() helpers in Texture2DConverter with one generic pure-Python uncompressed converter (unsigned scaled by format max, half/float clamped to [0,1] following the codebase's ASTC HDR convention, signed treated as SNORM) and reroutes the 17 affected CONV_TABLE entries to it; rgb9e5float() now rounds and clamps to [0,255].

Tests: the issue's script goes from 3 OK / 18 FAIL to 21/21 OK. New tests/test_texture2d_converter.py adds 21 tests, all passing. Full suite: 37 passed / 4 failed before, 58 passed / 4 failed after — the 4 failures are pre-existing sample-data failures, unchanged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncompressed 16-bit, half, float, RGB9e5 and signed texture formats fail to decode

1 participant